package main
import ( "fmt"
)

type Cat struct {
	name string
	age int
}

func main() {
	var allChan chan interface{}
	allChan = make(chan interface{},10)
	cat1 := Cat{name:"tom",age:10}
	cat2 := Cat{name:"tom~",age:100}
	allChan <- cat1
	allChan <- cat2
	allChan <- 10
	allChan <- "jack"
	// 取出
	newCat := <- allChan
	fmt.Printf("newCat=%T,newCat=%v\n",newCat,newCat)
	// 下面写法错误
	// fmt.Printf("newCat.name=%v\n",newCat.name)
	// 使用类型断言就行
	a := newCat.(Cat)
	fmt.Printf("newCat.name=%v\n",a.name)
}
